home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / PWAH2H10.ZIP / HSC2H.DOX < prev    next >
Text File  |  1995-07-16  |  5KB  |  136 lines

  1. ───────────────────────────────────────────────────────────────────────────────
  2.  
  3.          HSC2H V1.0 and how to use HSCOBJ.OBJ in your C/C++ programs
  4.  
  5. ───────────────────────────────────────────────────────────────────────────────
  6.                                                                 -Dox By Timecop
  7.  
  8. 1. Introduction.
  9.    ~~~~~~~~~~~~
  10.    One day I decided to write an intro in C and insert some music into it using
  11.    Chiken's famous HSCOBJ.OBJ.  I needed 2 things: an HSC2H converter and a
  12.    working example of how to use HSCOBJ.OBJ in C.  Since I didn't have either
  13.    of them I had to write both of them.  And then I said: "What the hell, I'll
  14.    release both things!"
  15.  
  16. 2. HSC2H converter.
  17.    ~~~~~~~~~~~~~~~
  18.    HSC2H is a nice simple utility that converts HSC binary music files to
  19.    include in your C/C++ programs.  It took me about 2 days to write it so I
  20.    think that it's not necessary to release the source because there is nothing
  21.    super-difficult in it.
  22.  
  23. 3. A Working example.
  24.    ~~~~~~~~~~~~~~~~~
  25.    Now here it took me a while to figure out what goes where.  Therefore I
  26.    said to myself: "What the hell, I'll release the source!"
  27.    Here you go:
  28.  
  29.    Name the file HSCTEST.C (extension should be .C)
  30.  
  31.    ----cut here----
  32. //////////////////////////////////////////////////////////////////////////////
  33. // Description : HSCOBJ.OBJ C/C++ Usage example                             //
  34. // Revision    : 1                                                          //
  35. // Compile     : Borland C++ v3.1+                                          //
  36. // Author      : Timecop [PWA]                                              //
  37. // Creation    : 07-02-95                                                   //
  38. // Last update : 07-02-95                                                   //
  39. //////////////////////////////////////////////////////////////////////////////
  40.  
  41. #include <conio.h>
  42. #include <dos.h>
  43. #include <stdio.h>
  44. #include <stdlib.h>
  45. #include "music.h"   // song converted with HSC2H
  46.  
  47. void far HSCPLAYER(void);
  48. unsigned int segment,offsett;
  49. int use_adlib;
  50.  
  51. void main()
  52.   {
  53.   asm           xor     ax,ax  // Detect adlib
  54.   asm           xor     bx,bx
  55.   asm           xor     cx,cx
  56.   asm           xor     dx,dx
  57.   asm           mov     ah,0x4
  58.     HSCPLAYER();
  59.   asm           jc      error
  60.  
  61.   use_adlib=1;
  62.   goto noerror;
  63.  
  64.  
  65.   error:;
  66.   printf("Error!  Unable to detect adlib on this system!\n");
  67.   use_adlib=0;
  68.  
  69.  
  70.   noerror:;
  71.   printf("Adlib detected.\n");
  72.   asm   mov     cx,0xffff
  73.   loopje:;
  74.   asm   loop    loopje
  75.  
  76.  
  77.   segment=FP_SEG(music);      // get segment
  78.   offsett=FP_OFF(music);      // get offset
  79.  
  80.  
  81.   if( !use_adlib ) exit(0);
  82.      asm        mov     ax,segment
  83.      asm        mov     es,ax
  84.      asm        mov     ax,offsett
  85.      asm        mov     si,ax
  86.      asm        xor     ax,ax
  87.      asm        xor     bx,bx
  88.      asm        xor     cx,cx
  89.      asm        xor     dx,dx
  90.      asm        mov     ah,0x0
  91.      asm        mov     bh,0x0
  92.      asm        mov     bl,0x0   // Function 0 : Start Playing
  93.  
  94.     HSCPLAYER();
  95.   printf("Now playing. Press any key to quit");
  96.  
  97.   while ( !kbhit() );
  98.  
  99.   asm           xor     ax,ax
  100.   asm           xor     bx,bx
  101.   asm           xor     cx,cx
  102.   asm           xor     dx,dx
  103.   asm           mov     ah,0x3     // Function 3 : Fade Playing
  104.     HSCPLAYER();
  105. delay(4000);
  106.  
  107.   asm           xor     ax,ax
  108.   asm           xor     bx,bx
  109.   asm           xor     cx,cx
  110.   asm           xor     dx,dx
  111.   asm           mov     ah,0x2     // Function 2 : Stop Playing
  112.     HSCPLAYER();                   // Also unloads the song from memory
  113.  
  114. printf("\n\n");
  115. }
  116.  
  117. //////////////////////////////////////////////////////////////////////////////
  118. //                            End Of File.                                  //
  119. //////////////////////////////////////////////////////////////////////////////
  120.    ----cut here----
  121.  
  122.    If you compile and link it right now, you will get a link error:
  123.    "Undefined symbol _HSCPLAYER() in module HSCTEST.C"
  124.    The only way that I found to fix that is to create a *project*. The only
  125.    things that you have to add to it are: HSCTEST.C and HSCOBJ.OBJ.  Now if
  126.    you try to compile HSCTEST.C from project you shouldn't get any warning or
  127.    error messages.
  128.  
  129. 4. Last words.
  130.    ~~~~~~~~~~
  131.    If you'll ever use the above example, I want you to give me a little greet
  132.    somewhere.  Hey didn't cost you anything!
  133.  
  134.  
  135.                                 END OF DOX
  136.